
<template>
  <div>
    <!-- 客户编辑dialog-->
    <el-dialog
      :title="title"
      :close-on-click-modal="false"
      v-dialogDrag
      :visible.sync="editVisible"
    >
      <el-form
        label-width="105px"
        ref="editForm"
        :model="editForm"
      >

        <el-form-item label="账号名称:" prop="names" :rules="[
                  {required: true, message:'请输入账号名称', trigger:'blur'}
                 ]">
          <el-input v-model="editForm.names"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <div class="footer-input">
          <el-button size="small" type="primary" @click="doSubmit()" v-noMoreClick
          >确定</el-button
        >
        <el-button size="small" @click="close()">取消</el-button>

        </div>

      </span>
    </el-dialog>
  </div>
</template>
<script>
  import {save} from '@/api/finance/tenantAccount.js'
export default {
  components: {
  },
  data () {
    return {
      areaLabel: {},
      method: '',
      title: '',
      editForm: {
        names: '',
        id: ''
      },
      editVisible: false,
      detailsVisible: false,
      tableData1: [],
      page: {
        pageSize: 10,
        pageNo: 1,
        total: 0
      },
      props: 1,
      dialogVisible: false,
      query: ''
    }
  },
  methods: {
  	handleClose(done) {
		this.$Msg.confirm({
			title:'您确定要关闭吗？',
			content:this.GLOBAL.FORM_CLOSE_TIPS,
			confirmCall:()=>{
				done();
			}
		})
	},
    select (e) {
      this.editForm.companyName = e.names
      this.editForm.companyId = e.id
      this.dialogVisible = false
      console.log(e)
    },
    init (method, editForm) {
      if (method === 'add') {
        this.editVisible = true
        this.$nextTick(() => {
          this.$refs.editForm.resetFields()
          // this.editForm = {}
        })

        this.editForm.companyName = ''
        this.editForm.companyId = ''
        this.editForm.productId = ''
        this.editForm.productName = ''
        this.editForm.creditQuatity = ''
        this.editForm.creditMoney = ''
        this.editForm.businessSurplusQuatity = ''
        this.editForm.businessSurplusMoney = ''
        this.editForm.id = ''
        this.title = '新增客户'
      } else if (method === 'edit') {
        this.editVisible = true
        this.method = method
        console.log(editForm)
        this.editForm = editForm
        console.log(editForm.countyCode)
        this.$nextTick(() => {
          this.$refs.editForm.resetFields()
          this.editForm = editForm
        })

        this.title = '修改客户'
      }
      console.log(this.method)
    },
    getArea1 (e) {
      if (e.province !== '' && e.city !== '' && e.district !== '') {
        this.editForm.countyCode = JSON.stringify(e)
      } else {
        this.editForm.countyCode = ''
      }
    },
    close () {
      this.editVisible = false
    },
    doSubmit () {
      this.$refs['editForm'].validate((valid) => {
        if (valid) {
          save(this.editForm).then((res) => {
            if (res.data.code === '200') {
              this.$message({
                message: '编辑成功',
                type: 'success'
              })
              this.editVisible = false
              this.$emit('refreshDataList')
            }
          })
        }
      })
    }
  },
  mounted () {
    this.getList(this.page, 1)
  }
}
</script>
<style lang="scss" scoped>
::v-deep .el-dialog{
  .el-form{
    .el-input__inner{
      width: 320px;
    }
    .inputAppend-wrapper{
      .el-input__inner{
        width: 282px;
      }
    }
  }
}
</style>
